package cn.edu.nju.askme.model;
// default package

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;


/**
 * User entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name="user"
    ,catalog="askme"
)

public class User  implements java.io.Serializable {


    // Fields    

     private Integer id;
     private String email;
     private String username;
     private String password;
     private Set<Paper> papers = new HashSet<Paper>(0);
     private Set<PaperAnswer> paperAnswers = new HashSet<PaperAnswer>(0);


    // Constructors

    /** default constructor */
    public User() {
    }

	/** minimal constructor */
    public User(String email, String username, String password) {
        this.email = email;
        this.username = username;
        this.password = password;
    }
    
    /** full constructor */
    public User(String email, String username, String password, Set<Paper> papers, Set<PaperAnswer> paperAnswers) {
        this.email = email;
        this.username = username;
        this.password = password;
        this.papers = papers;
        this.paperAnswers = paperAnswers;
    }

   
    // Property accessors
    @Id @GeneratedValue(strategy=IDENTITY)
    
    @Column(name="id", unique=true, nullable=false)

    public Integer getId() {
        return this.id;
    }
    
    public void setId(Integer id) {
        this.id = id;
    }
    
    @Column(name="email", nullable=false, length=45)

    public String getEmail() {
        return this.email;
    }
    
    public void setEmail(String email) {
        this.email = email;
    }
    
    @Column(name="username", nullable=false, length=45)

    public String getUsername() {
        return this.username;
    }
    
    public void setUsername(String username) {
        this.username = username;
    }
    
    @Column(name="password", nullable=false, length=45)

    public String getPassword() {
        return this.password;
    }
    
    public void setPassword(String password) {
        this.password = password;
    }
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="user")

    public Set<Paper> getPapers() {
        return this.papers;
    }
    
    public void setPapers(Set<Paper> papers) {
        this.papers = papers;
    }
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="user")

    public Set<PaperAnswer> getPaperAnswers() {
        return this.paperAnswers;
    }
    
    public void setPaperAnswers(Set<PaperAnswer> paperAnswers) {
        this.paperAnswers = paperAnswers;
    }
   








}